Golang flag.Uint() function example
package flag
Uint defines a uint flag with specified name(1st parameter), default value(2nd parameter), and usage string(3rd parameter). The return value is the address of a uint variable that stores the value of the flag.
Golang flag.Uint() function usage example
package main
import (
"flag"
"fmt"
"strconv"
)
func main() {
port := flag.Uint("port", 8080, "Port to listen. Default is 8080")
flag.Parse()
fmt.Println(flag.Lookup("port")) // print the Flag struct
fmt.Printf("Port number is %s\n ", strconv.Itoa(int(*port)))
}
Output :
&{port Port to listen. Default is 8080 8080 8080}
Port number is 8080
Reference :
Advertisement
Something interesting
Tutorials
+6.5k Golang : Combine slices of complex numbers and operation example
+14.2k Golang : syscall.Socket example
+21.2k Golang : How to force compile or remove object files first before rebuild?
+9.1k Golang : Intercept and compare HTTP response code example
+17.1k Golang : Capture stdout of a child process and act according to the result
+5.6k Javascript : How to refresh page with JQuery ?
+7.9k Javascript : Put image into Chrome browser's console
+22k Fix "Failed to start php5-fpm.service: Unit php5-fpm.service is masked."
+9k Golang : Build and compile multiple source files
+27.4k Golang : Convert CSV data to JSON format and save to file
+8.1k Golang : Randomize letters from a string example